<%@ page language="java" contentType="text/html; charset=utf-8" errorPage="/404.jsp" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <style type="text/css">
        @import url("<c:url value='/css/main.css'/>");
    </style>
    <title>房屋信息列表</title>
</head>
<body>

<c:choose>
<c:when test="${empty pageInfo}">
    <%--	判断 request 中是否有分页，没有去请求	--%>
    <jsp:forward page="/house/list.action"/>
</c:when>
<c:otherwise>
    <%--	有了分页，显示	--%>

<div class="div_main">
    <div class="div_header">房屋信息管理-房屋列表</div>
    <div>
	    <span id="span_add">
		   <a href="<c:url value='/view/house/add.jsp'/>" target="pageBox">添加房屋</a>
		</span>
    </div>
    <div class="div_data">
        <table class="tab_list">
            <tr>
                <th>序号</th>
                <th>地区</th>
                <th>小区</th>
                <th>单元</th>
                <th>楼层</th>
<%--                <th>房号</th>--%>
<%--                <th>面积</th>--%>
<%--                <th>朝向</th>--%>
<%--                <th>装修</th>--%>
<%--                <th>是否有双气</th>--%>
<%--                <th>限住人数</th>--%>
<%--                <th>配套设施</th>--%>
<%--                <th>日租</th>--%>
<%--                <th>房屋状态</th>--%>
<%--                <th>房屋图片</th>--%>
<%--                <th>地址</th>--%>
<%--                <th>添加时间</th>--%>
<%--                <th>信息修改时间</th>--%>
                <th>操作</th>
            </tr>
            <c:forEach items="${pageInfo.list}" var="lessee">
                <tr>
                    <td>${lessee.hid}</td>
                    <td>${lessee.harea}</td>
                    <td>${lessee.hcommunity}</td>
                    <td>${lessee.hunitnumber}</td>
                    <td>${lessee.hfloor}</td>
<%--                    <td>${c.hroomno}</td>--%>
<%--                    <td>${c.hacreage}</td>--%>
<%--                    <td>${c.hdirectionStr}</td>--%>
<%--                    <td>${c.hfitmentStr}</td>--%>
<%--                    <td>${c.hisdoubleairStr}</td>--%>
<%--                    <td>${c.hlimit}</td>--%>
<%--                    <td>${c.hfacility}</td>--%>
<%--                    <td>${c.hprice}</td>--%>
<%--                    <td>${c.hstatusStr}</td>--%>

<%--                    <td>--%>
<%--                        <img src="${pageContext.request.contextPath}/image/${c.himg}" alt="${c.himg}" width="20px"--%>
<%--                             height="20px">--%>
<%--                    </td>--%>
<%--                    <td>${c.haddress}</td>--%>
<%--                    <td>${c.haddtimeStr}</td>--%>
<%--                    <td>${c.hupdatetimeStr}</td>--%>

                    <td>
                        <a href="${pageContext.request.contextPath}/house/getOneByHid.action?hid=${lessee.hid}">详情</a>
                        &nbsp;&nbsp;
<%--                        <a href="${pageContext.request.contextPath}/view/house/update.jsp">编辑</a>--%>
                        <a href="${pageContext.request.contextPath}/house/getOneByHid.action?hid=${lessee.hid}&method=update">编辑</a>

                        &nbsp;&nbsp;
                        <a href="#" onclick="confirmDelete(${lessee.hid})">删除</a>
                    </td>
                </tr>
            </c:forEach>

        </table>
    </div>
    <div class="div_fenye">
        <span id="span_jilu">共有 ${pageInfo.total } 条记录，第 ${pageInfo.pageNum} / ${pageInfo.pages} 页 </span>
        <span id="span_fenye">
             <a href="${pageContext.request.contextPath}/house/list.action?pageNo=${pageInfo.navigateFirstPage}">第一页</a>

				<c:if test="${pageInfo.hasPreviousPage}">
                    <a href="${pageContext.request.contextPath}/house/list.action?pageNo=${pageInfo.pageNum-1}">上一页</a>
                </c:if>

			<c:if test="${pageInfo.hasNextPage}">
                <a href="${pageContext.request.contextPath}/house/list.action?pageNo=${pageInfo.pageNum+1}">下一页</a>
            </c:if>

            <a href="${pageContext.request.contextPath}/house/list.action?pageNo=${pageInfo.navigateLastPage}">最后一页</a>
				</span>
    </div>
</div>
<script>
    function confirmDelete(id) {
        if (confirm("确定要删除码？")) {
            window.location="${pageContext.request.contextPath}/house/deleteOneByHid.action?hid=" + id;
            // 重定向
        }
        return false;
    }


    </c:otherwise>
    </c:choose>


</script>
</body>
</html>